blob: dfd4bb8327aaa726932c467e81888fc1f4109d10 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
---
import BlogCard from '@/components/BlogCard.astro'
import Breadcrumbs from '@/components/Breadcrumbs.astro'
import PageHead from '@/components/PageHead.astro'
import Layout from '@/layouts/Layout.astro'
import { getAllTags, getPostsByTag } from '@/lib/data-utils'
export async function getStaticPaths() {
const tagMap = await getAllTags()
const uniqueTags = Array.from(tagMap.keys())
return Promise.all(
uniqueTags.map(async (tag) => {
const posts = await getPostsByTag(tag)
return {
params: { id: tag },
props: {
tag,
posts,
},
}
}),
)
}
const { tag, posts } = Astro.props
---
<Layout class="max-w-3xl">
<PageHead
slot="head"
title={`Posts tagged with "${tag}"`}
description={`A collection of posts tagged with ${tag}.`}
noindex
/>
<Breadcrumbs
items={[
{ href: '/tags', label: 'Tags', icon: 'lucide:tags' },
{ label: tag, icon: 'lucide:tag' },
]}
/>
<ul class="flex flex-col gap-y-4">
{
posts.map((post) => (
<li>
<BlogCard entry={post} />
</li>
))
}
</ul>
</Layout>
|